//
//  YWHandleStatusCell.m
//  百布业务
//
//  Created by 陈炳桦 on 15/11/5.
//  Copyright © 2015年 陈炳桦. All rights reserved.
//

#import "YWHandleStatusCell.h"

@interface YWHandleStatusCell()

// 时间
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

// 操作人
@property (weak, nonatomic) IBOutlet UILabel *operatorLabel;

// 状态
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;

// 备注
@property (weak, nonatomic) IBOutlet UILabel *remarksLabel;

@end

@implementation YWHandleStatusCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setHandleStatus:(YWHandleStatus *)handleStatus{
    _handleStatus = handleStatus;
    
    // 时间
    self.timeLabel.text = [self getTime:handleStatus.createTime];

    // 操作人
    if ([handleStatus.myOperator isEmpty] || handleStatus.myOperator == nil) {
        self.operatorLabel.text = @"无";
    }else{
        self.operatorLabel.text = handleStatus.myOperator;
    }
    
    // 状态
    if ([handleStatus.handleStatusName isEmpty] || handleStatus.handleStatusName == nil) {
        self.statusLabel.text = @"无";
    }else{
        self.statusLabel.text = handleStatus.handleStatusName;
    }
    
    // 备注
    if ([handleStatus.handleDesc isEmpty] || handleStatus.handleDesc == nil ){
        self.remarksLabel.text = @"无";
    }else{
        self.remarksLabel.text = handleStatus.handleDesc;
    }
    
}

// 计算时间
- (NSString *)getTime:(NSString *)time{
    
    NSTimeInterval timeInterval = [time doubleValue] / 1000.0;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"MM-dd HH:mm";

    return [formatter stringFromDate:date];
    
}

// 重写setFrame实现间距
- (void)setFrame:(CGRect)frame
{
    int space = 5;
    frame.size.height = 100;
    frame.origin.y += space;
    
    [super setFrame:frame];
}

@end
